Good morning Jack,
To answer your previous question about the markers - currently, AFAIK,
there is no way to access the markers from a given feed to change the
color, etc (the only thing you can do is catch the click event on each
marker, which doesn't necessarily help you too much here.) On the
other hand, another option you do have is that you could setup a
"proxy" on your server to serve the KML files. IE: yoursite.com/
kml_proxy.(php?, asp?,?) , and then you could setup that script to
parse the files and either a)add the markers manually or b)rewrite the
file with the desired colored placemarks in the file itself. This
isn't necessarily the easiest solution, but is the only one I can
think of currently.
As for your issue with the weather map, adding the ,
{preserveViewport:true} should be exactly what you need to solve that
problem.
On May 11, 8:02 am, Jack Berberette <[email protected]> wrote:
> I think I figured it out. I had to set the zoom level in myOptions then add
> {preserveViewport:true} to the variables. It seems to be working fine....I
> hope I did this right.
>
> Jack
>
> On Tue, May 11, 2010 at 9:27 AM, Jack Berberette <[email protected]> wrote:
> > Hello Everyone,
>
> > Sorry to be a burden. The map is up and working great thanks to all of
> > your help. My boss loved the map but tasked me with adding a weather feed
> > as well. I added the feed and the weather shows up but the map is now
> > zoomed all the way out instead of being at the normal zoom level.
>
> > Brad gave me a great code snippet that fixed the zoom issue on the map
> > before I tried adding the weather feed:
> > {preserveViewport:true}
>
> > I tried implementing this when adding the weather feed but it doesn't seem
> > to be taking affect. I think I'm getting the feed order or something
> > incorrect. We will probably be adding more feeds as time goes on so I'm
> > trying to figure this out.
>
> > Here is the map that I added the weather to:
> >http://www.gamecarver.com/viperapp_weather.html
>
> > Here is the map before I added the weather feed (this one works correctly
> > and has the proper zoom based on current location):
> >http://www.gamecarver.com/viperapp.html
>
> > Here is the code for the map with the weather feed...I really appreciate
> > your time on this...you guys rock!
>
> > Jack
>
> > <html>
> > <head>
> > <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
> > <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
> > <title>VIPER Traffic and Hazmat LIVE</title>
> > <script type="text/javascript" src="
> >http://maps.google.com/maps/api/js?sensor=true"></script>
> > <script type="text/javascript">
> > var initialLocation;
> > var statepolice = new google.maps.LatLng(37.502168, -77.542212);
> > var Hazmat;
> > var RichmondTraffic;
> > var Weather;
> > var trafficLayer;
> > var map;
>
> > function initialize() {
> > var myOptions = {
> > zoom: 3,
>
> > mapTypeId: google.maps.MapTypeId.ROADMAP
> > };
> > //Notice no "var" before variable assignment, that is taken care of above.
> > // Use ,{preserveViewport:true} to keep magnification in check...
>
> > map = new google.maps.Map(document.getElementById("map_canvas"),
> > myOptions);
> > Hazmat = new google.maps.KmlLayer('
> >https://cop.vdem.virginia.gov/gis_feeds/GeoRSS2.ashx'<https://cop.vdem.virginia.gov/gis_feeds/GeoRSS2.ashx%27>
> > );
>
> > RichmondTraffic = new google.maps.KmlLayer('
> >http://map.richmondgov.com/Bing/Traffic/georssfeed.ashx
> > ',{preserveViewport:true});
> > Weather = new google.maps.KmlLayer('
> >http://www.metaltoad.com/sites/all/modules/custom/gearth/kmlweather/w...<http://www.metaltoad.com/sites/all/modules/custom/gearth/kmlweather/w...>
> > );
>
> > trafficLayer = new google.maps.TrafficLayer();
>
> > //Just to demonstrate the use of toggleLayer
> > toggleLayer(Hazmat);
> > toggleLayer(RichmondTraffic);
> > toggleLayer(Weather);
> > toggleLayer(trafficLayer);
>
> > // Safari supports the W3C Geolocation method
> > if(navigator.geolocation) {
> > navigator.geolocation.getCurrentPosition(function(position) {
> > initialLocation = new
> > google.maps.LatLng(position.coords.latitude,position.coords.longitude);
> > var placeMarker = new google.maps.Marker({
> > position: initialLocation,
> > map: map,
> > });
> > map.setCenter(initialLocation);
> > }, function() {
> > handleNoGeolocation(browserSupportFlag);
> > });
> > } else {
> > // Browser doesn't support Geolocation
> > handleNoGeolocation();
> > }
>
> > function handleNoGeolocation() {
> > initialLocation = statepolice;
> > map.setCenter(initialLocation);
> > }
> > }
>
> > function toggleLayer(layer) {
> > if (layer.getMap()) {
> > layer.setMap(null);
> > } else {
> > layer.setMap(map);
> > }
> > }
>
> > </script>
> > <style>
> > DIV.container {
> > width: 100%;
> > height: 50px;
> > align: center;
> > background-image: url(
> >http://www.gamecarver.com/img/appimages/DivHeaderBG2.png);
> > // display: table-cell;
> > vertical-align: middle;
> > font-size:medium;
> > font-family: sans-serif;
> > color: white;
> > text-align: center;
> > font-weight: bold;
> > }
> > </style>
> > </head>
> > <body style="margin:0px; padding:0px;" onload="initialize()">
> > <div style="width:100%; height:385px">
> > <div class="container" ><img src="
> >http://www.gamecarver.com/img/appimages/Header1.png"</div>
>
> > <div id="map_canvas" style="width:100%; height:100%"></div>
> > <div align="center" style="background-image: url(
> >http://www.gamecarver.com/img/appimages/DivHeaderBG2.png);height: 25px;
> > width: 100%">
> > <button onclick="toggleLayer(RichmondTraffic)">Accidents</button>
>
> > <button onclick="toggleLayer(Hazmat)">Hazmat</button>
> > <button onclick="toggleLayer(trafficLayer)">Traffic</button>
> > <button onclick="toggleLayer(Weather)">Weather</button>
>
> > </div>
> > </div>
>
> > </body>
> > </html>
>
> > On Mon, May 10, 2010 at 10:50 PM, Jack Berberette <[email protected]>wrote:
>
> >> Brad that worked like a charm! Thanks for hanging in there with me. And
> >> thanks to everyone who helped with this....I really can't begin to say how
> >> grateful I am to have found such a cool group of people! I am not a
> >> programmer but am doing the best I can to learn enough to be of help for
> >> the
> >> agency.
>
> >> Out of curiosity...does anyone know how to set the colors for the markers
> >> based on the feed? Like Red for Hazmat, Green for RichmondTraffic, etc...
> >> I found a bunch of information but it looked like it only applied to
> >> layers
> >> with static points. Is there a way to basically set the marker from feed
> >> name?
>
> >> Once again....thanks to everyone...my team mates are going to be so
> >> excited about this!
>
> >> You guys Rock!
>
> >> Jack
> >> VIPER Program Manager
> >> Virginia Department of Emergency Management
> >>https://cop.vdem.virginia.gov/viper
>
> >> On Mon, May 10, 2010 at 10:14 PM, Brad <[email protected]> wrote:
>
> >>> If RichmondTraffic is the only one giving you issues, than you can
> >>> change this:
> >>> RichmondTraffic = new google.maps.KmlLayer('
> >>>http://map.richmondgov.com/Bing/Traffic/georssfeed.ashx'<http://map.richmondgov.com/Bing/Traffic/georssfeed.ashx%27>
> >>> );
>
> >>> to this:
> >>> RichmondTraffic = new google.maps.KmlLayer('
> >>>http://map.richmondgov.com/Bing/Traffic/georssfeed.ashx
> >>> ',{preserveViewport:true});
>
> >>> (you might consider adding ",{preserveViewport:true}" to all the
> >>> KmlLayer calls as that will maintain the viewport when all the layers
> >>> are added removed - this isn't an issue now but could be in the future
> >>> depending on if the feed content changes)
>
> >>> On May 10, 6:51 pm, Jason Sanford <[email protected]> wrote:
> >>> > I copy and pasted your code and made some changes to it. I'm still
> >>> having
> >>> > issues with your traffic layer acting weird when toggling it but the
> >>> other
> >>> > two layers toggle fine.
>
> >>> >http://test.geojason.info/viper.html
>
> >>> > You can see the code there and compare to yours.
>
> >>> > On Mon, May 10, 2010 at 8:45 PM, Jack Berberette <[email protected]>
> >>> wrote:
> >>> > > Thanks for taking your time in this Brad :) I have implemented the
> >>> changes
> >>> > > but I must something wrong because the map area is just grey now.
> >>> Here's
> >>> > > the link to the page:http://www.gamecarver.com/viperapp3.html
>
> >>> > > Here's the link to a page that has the maps on:
> >>> > >http://www.gamecarver.com/viperapp2.html(this<http://www.gamecarver.com/viperapp2.html%28this>was
> >>> > > my first attempt)
>
> >>> > > Here's the code after the changes....I'm really sorry to be a burden:
>
> >>> > > <html>
> >>> > > <head>
> >>> > > <meta name="viewport" content="initial-scale=1.0, user-scalable=no"
> >>> />
> >>> > > <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
> >>> > > <title>VIPER Traffic and Hazmat LIVE</title>
> >>> > > <script type="text/javascript" src="
> >>> > >http://maps.google.com/maps/api/js?sensor=true"></script>
> >>> > > <script type="text/javascript">
> >>> > > var initialLocation;
> >>> > > var statepolice = new google.maps.LatLng(37.502168, -77.542212);
> >>> > > var Hazmat;
> >>> > > var RichmondTraffic;
> >>> > > var StateShelters;
> >>> > > var trafficLayer;
> >>> > > var map;
>
> >>> > > function toggleLayer(layer) {
> >>> > > if (layer.getMap()) {
> >>> > > layer.setMap(null);
> >>> > > } else {
> >>> > > layer.setMap(map);
> >>> > > }
> >>> > > }
>
> >>> > > function initialize() {
> >>> > > var myOptions = {
> >>> > > zoom: 14,
> >>> > > mapTypeId: google.maps.MapTypeId.ROADMAP
> >>> > > };
> >>> > > var map = new
> >>> google.maps.Map(document.getElementById("map_canvas"),
> >>> > > myOptions);
> >>> > > var map = new google.maps.KmlLayer('
> >>> > >https://cop.vdem.virginia.gov/gis_feeds/GeoRSS2.ashx'<
> >>>https://cop.vdem.virginia.gov/gis_feeds/GeoRSS2.ashx%27>
> >>> > > );
> >>> > > Hazmat.setMap(map);
> >>> > > var map = new google.maps.KmlLayer('
> >>> > >http://map.richmondgov.com/Bing/Traffic/georssfeed.ashx'<
> >>>http://map.richmondgov.com/Bing/Traffic/georssfeed.ashx%27>
> >>> > > );
> >>> > > RichmondTraffic.setMap(map);
> >>> > > var map = new google.maps.KmlLayer('
> >>> > >https://cop.vdem.virginia.gov/gis_feeds/ShelterGeoRSS.ashx'<
> >>>https://cop.vdem.virginia.gov/gis_feeds/ShelterGeoRSS.ashx%27>
> >>> > > );
> >>> > > StateShelters.setMap(map);
> >>> > > var map = new google.maps.TrafficLayer();
> >>> > > trafficLayer.setMap(map);
>
> >>> > > // Safari supports the W3C Geolocation method
> >>> > > if(navigator.geolocation) {
> >>> > > navigator.geolocation.getCurrentPosition(function(position) {
> >>> > > initialLocation = new
>
> ...
>
> read more »
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.