Gmap3 - Forum

Gmap3 exchange platform

You are not logged in.

Ads
(server costs 27.50€ per month)


#1 2012-01-05 16:39:54

sam
Member
Registered: 2012-01-05
Posts: 7

[solved] addMarkers and custom icon

Hi,

I add multiple markers using the addMarkers function but i don't find any documentation to use custom icon , like with "addMarker"

my code :

  $("#gmap").gmap3(
   { action: 'init',
      options:{
      center:[47.27850107780644,-2.392616545043893],
      zoom: 14,
              mapTypeControl: true,
              mapTypeControlOptions: {
                style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
              },
              navigationControl: true,
              scrollwheel: true,
              streetViewControl: true      
      },
      events:{
              bounds_changed: function(map){
                console.log(map.getBounds().getCenter());
                var bounds = map.getBounds();
                var ne = bounds.getNorthEast();
                var sw = bounds.getSouthWest();
              }
            }
      
    },
    { action: 'addMarkers',
            markers:[
              {lat:47.2807359, lng:-2.3830308000000286, data:'my place 1',  icon:new google.maps.MarkerImage("http://www.mysite.com/static/css/img/pin1.png")},
              {lat:47.2807359, lng:-2.3830308000000286, data:'my place 2',  icon:new google.maps.MarkerImage("http://www.mysite.com/static/css/img/pin2.png")},
            ],
            marker:{
              options:{
                draggable: false
              }
            }
    }
  );

any idea ?

thanks

Last edited by sam (2012-01-05 18:05:20)

Offline

Ads
(server costs 27.50€ per month)


#2 2012-01-05 16:45:33

mrmustache
Member
Registered: 2011-12-22
Posts: 15

Re: [solved] addMarkers and custom icon

Hey Sam,

it should look like this:

marker:{
options:{
draggable: false,
icon : new google.maps.MarkerImage('yourImage.png')
}
}

Last edited by mrmustache (2012-01-05 16:45:56)

Offline

#3 2012-01-05 16:51:18

sam
Member
Registered: 2012-01-05
Posts: 7

Re: [solved] addMarkers and custom icon

thanks  but how do i set a different icon for each location ?

Offline

#4 2012-01-05 18:04:56

sam
Member
Registered: 2012-01-05
Posts: 7

Re: [solved] addMarkers and custom icon

Ok i found the solution by myself  :

  $("#gmap").gmap3(
   { action: 'init',
      options:{
      center:[47.27850107780644,-2.392616545043893],
      zoom: 14,
              mapTypeControl: true,
              mapTypeControlOptions: {
                style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
              },
              navigationControl: true,
              scrollwheel: true,
              streetViewControl: true      
      },
      events:{
              bounds_changed: function(map){
                console.log(map.getBounds().getCenter());
                var bounds = map.getBounds();
                var ne = bounds.getNorthEast();
                var sw = bounds.getSouthWest();
              }
            }
      
    },
    { action: 'addMarkers',
            markers:[
              {lat:47.2807359, lng:-2.3830308000000286, data:'name 1', options : { icon:new google.maps.MarkerImage("http://www.mysite.fr/static/css/img/pin_1.png") }},
              {lat:47.285448, lng:-2.3932360000000017, data:'name 2', options : { icon:new google.maps.MarkerImage("http://www.mysite.fr/static/css/img/pin_2.png") }}
            ],
            marker:{
              options:{
                draggable: false                
              }
            }            
    }
  );
 
});

great library !

Offline

#5 2012-08-30 13:28:51

Pimpy.T
Member
Registered: 2012-08-30
Posts: 1

Re: [solved] addMarkers and custom icon

Solved for me as well Sam, Thank you, multiple custom markers in combination with clusters using an external array of dynamicly generated data:

var panden = [ 
	{	
		lat:42.782909,	
		lng:-73.930679,	
		data:{		
			drive:false,		
			zip:3064,		
			url:"http://nl.cameloteurope.com/?id=688&level=1&guard_man=189&args=&panden_id=2881&property_id=2881&wtlive=Rotterdam1",		
			city:"Rotterdam1",		
			aantal:"2",		
			type:"Tijdelijke woonruimte",		
			typeId:"1" 	
		},	
		options:{icon: new google.maps.MarkerImage("/images/googlemarker1.png")},
	},
	{	
		lat:50.848930,	
		lng:5.688430,	
		data:{		
			drive:false,		
			zip:6211,		
			url:"http://nl.cameloteurope.com/?id=688&level=1&guard_man=367&args=&panden_id=2988&property_id=2988&wtlive=Maastricht",		city:"Maastricht",		
			aantal:"1",		
			type:"Tijdelijke werkruimte",		
			typeId:"3" 	
		},	
		options:{icon: new google.maps.MarkerImage("/images/googlemarker3.png")},
	}
]

View the live map: http://www.cameloteurope.com/google.php

Offline

#6 2012-09-20 04:03:25

arcee123
Member
Registered: 2012-09-11
Posts: 6

Re: [solved] addMarkers and custom icon

Hi,
I'm trying to do the same thing, however it appears that when the JSON comes through the JQUERY's AJAX Call, the icon does not want to show:

is there a special format to get the icons to show when coming through an AJAX Call?
Thanks.

Offline

#7 2012-09-20 04:13:35

arcee123
Member
Registered: 2012-09-11
Posts: 6

Re: [solved] addMarkers and custom icon

sorry, I hit the button to early...
I realize this subject is closed, but I didn't want to start a new thread if none were needed.
(please correct me if I'm wrong...)

I'm trying to get this to work:
http://jsfiddle.net/arcee123/S8kd3/74/

Using the formatted JSON from above, I cannot get the markers to appear in their specialized icons.

please help.
Thank you.

Offline

#8 2012-10-18 10:07:04

neokio
Member
Registered: 2012-10-18
Posts: 1

Re: [solved] addMarkers and custom icon

This gets ridiculously inefficient ...
If I have 5,000 markers but only 5 icons, it makes much more sense to declare the icons in the JS, and add a simple identifier in the JSON.

Is there a way to do something like this?

// JSON generated by PHP or whatever
var myMarkers = [
	{ lat:12.34567, lng:123.4567, data:"Blah blah", options: { icon: img1 } },
	{ lat:21.23456, lng:123.4567, data:"Blah blah", options: { icon: img2 } },
	{ lat:32.12345, lng:123.4567, data:"Blah blah", options: { icon: img3 } },
	{ lat:43.21234, lng:123.4567, data:"Blah blah", options: { icon: img1 } },
	{ lat:54.32123, lng:123.4567, data:"Blah blah", options: { icon: img2 } },
	{ lat:65.43212, lng:123.4567, data:"Blah blah", options: { icon: img3 } },
	{ lat:76.54321, lng:123.4567, data:"Blah blah", options: { icon: img1 } }
	// ... add 5000 more records here ...
	];

var img1 = new google.maps.MarkerImage('http://maps.gstatic.com/mapfiles/ridefinder-images/mm_20_red.png');
var img2 = new google.maps.MarkerImage('http://maps.gstatic.com/mapfiles/ridefinder-images/mm_20_green.png');
var img3 = new google.maps.MarkerImage('http://maps.gstatic.com/mapfiles/ridefinder-images/mm_20_blue.png');
var shadow = new google.maps.MarkerImage('http://maps.gstatic.com/mapfiles/ridefinder-images/mm_20_shadow.png');

$('#map_canvas').gmap3({
		action: 'init'
	},{
		action: 'addMarkers',
		markers: myMarkers,
		marker: {
			options:{
				// icon: markers.data.options.icon, or nothing, or what??
				shadow: myShadow
			}
		}
	}
);

Offline

#9 2015-02-21 04:17:25

Sathiya
Member
Registered: 2015-02-21
Posts: 1

Re: [solved] addMarkers and custom icon

NIce Coding ... !!!!

__________________
Arslan ( Dill E Nadan)

Offline

#10 2016-02-06 12:33:22

Karrahahu1
Member
Registered: 2016-02-06
Posts: 1

Re: [solved] addMarkers and custom icon

However it appears that when the JSON comes through the JQUERY's AJAX Call,???



Ali

Last edited by Karrahahu1 (2016-02-06 12:33:41)

Offline

#11 2017-08-09 13:30:33

ronnykinge
Member
Registered: 2017-04-06
Posts: 2,386

Re: [solved] addMarkers and custom icon

Capabilities Summary Sample – Other Job Search Documents.  Home Uncategorized How to write an introduction paragraph for a persuasive essay.  school essay help 
GTA: Chinatown Wars Built specifically for portable devices, the. Thank You Notes for Money Samples and Wording Ideas. Free personal identity papers, essays, and research papers.  common application essay help your  We work with leading partners and use cuttingedge technologies to develop. Sample Essay On The Topic Of Education System In USA. 
As Ferguson wrote, after 9/11 Huntington's model seemed to make sense of 'an.  case study depersonalization disorder  If we identify sound,. project, no matter how much pleasure and profit benefit to lowerpaid workers. With this review, we explore the practices of artsbased educational research as.

Offline

#12 2017-08-09 13:32:10

ronnykinge
Member
Registered: 2017-04-06
Posts: 2,386

Re: [solved] addMarkers and custom icon

here to download the PDF file containing sample r sum s and. Written Report Format for Citing Scientific Research Sources. The quality of your resume determines whether or not it moves from an inbox to someone's desk.  how long does a personal statement have to be for medical school  Air pollution causes effects and solutions essay custom writing. 
Essay/Term paper: Posttraumatic stress disorder Dream Essays. deficiency The thesis presents the underlining theory of the binary SCC and its.  Plan and host community building events at NakedCity Gallery —Host. help you achieve Someone writing an essay on my future nature of analyzing a. Write the sketch from the thirdperson perspective.  newview essay services 
SQL SELECT statement database basics tutorial: learning, writing. Guidelines for Writing a Professional Resume The following guidelines will.  Arthur Schopenhauer was famed for his unflinching philosophical pessimism.  legit essay writers 
told in the omniscient third person (instead of allowing Janie her voice outright ). When it comes to writing college papers there is a lot of work involved. View our galleries example of persuasive essay on global warming, media analysis essay topics and 150 words essay a conclusion paragraph for an essay.  writing services singapore  professional and financial heights, both for the organization and self, through.

Offline

Board footer

Powered by FluxBB